﻿Shader "Cg basic shader" {
	SubShader {//unity chooses the subshader that fits the GPU best
		Tags {"Queue" = "Transparent"}
		pass { // some shaders require multiple passes
			Cull Front
			ZWrite Off
			Blend SrcAlpha OneMinusSrcAlpha
			
			CGPROGRAM //the Cg's beginning
			
			#pragma vertex vert
				//define the vertex shader entry function
			#pragma fragment frag
				//define the fragment shader entry function
			
			//float4 vert(float4 vertexPos:POSITION):SV_POSITION
			//{
			//	return mul(UNITY_MATRIX_MVP,float4(1.0,1.0,1.0,1.0)*vertexPos);
			//}
			
			struct vertexOutput {
				float4 pos:SV_POSITION;
				float4 col:TEXCOORD0;
			};
			
			vertexOutput vert(float4 vertexPos:POSITION)
			{
				vertexOutput output;
				output.pos = mul(UNITY_MATRIX_MVP,vertexPos);
				output.col = vertexPos + float4(0.5,0.5,0.5,0.0);
				
				return output;
			}
			
			float4 frag(vertexOutput input):COLOR
			{
				//return float4(0.6,1.0,0.0,1.0);
				//if (input.col.y > 0.5)
				//{
				//	discard;
				//}
				input.col.w = 0.3;
				return input.col;
			}
			
			ENDCG
			}
			
			pass { // some shaders require multiple passes
			Cull Back
			ZWrite Off
			Blend SrcAlpha OneMinusSrcAlpha
			
			CGPROGRAM //the Cg's beginning
			
			#pragma vertex vert
				//define the vertex shader entry function
			#pragma fragment frag
				//define the fragment shader entry function
			
			//float4 vert(float4 vertexPos:POSITION):SV_POSITION
			//{
			//	return mul(UNITY_MATRIX_MVP,float4(1.0,1.0,1.0,1.0)*vertexPos);
			//}
			
			struct vertexOutput {
				float4 pos:SV_POSITION;
				float4 col:TEXCOORD0;
			};
			
			vertexOutput vert(float4 vertexPos:POSITION)
			{
				vertexOutput output;
				output.pos = mul(UNITY_MATRIX_MVP,vertexPos);
				output.col = vertexPos + float4(0.5,0.5,0.5,0.0);
				
				return output;
			}
			
			float4 frag(vertexOutput input):COLOR
			{
				//return float4(0.6,1.0,0.0,1.0);
				//if (input.col.y > 0.5)
				//{
				//	discard;
				//}
				input.col.w = 0.3;
				return input.col;
			}
			
			ENDCG
			}
	}
}
